package com.test.mylotterysystem.service.MQ;

import com.test.mylotterysystem.comment.errorCode.ServiceErrorCode;
import com.test.mylotterysystem.comment.exception.ServiceException;
import com.test.mylotterysystem.comment.utils.JacksonUtil;
import com.test.mylotterysystem.constants.Constants;
import com.test.mylotterysystem.controller.Param.DrawPrizeParam;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@RabbitListener(queues = Constants.QUEUE_NAME)
@Component
public class RabbitMQListener {
    @RabbitHandler
    public void handler(Map<String, String> map){
        if (map.isEmpty()) {
            throw new ServiceException(ServiceErrorCode.RABBIT_MQ_MESSAGE_IS_EMPTY);
        }

        DrawPrizeParam message = JacksonUtil.readValue(map.get("message"), DrawPrizeParam.class);

        // TODO
    }
}
